package repositories

import (
	"context"
	"go.mongodb.org/mongo-driver/bson"
	"signature-service/global"
)

type ScanConfig struct {
	ChainId         uint   `bson:"chainId"`
	ChainName       string `bson:"chainName"`
	RpcUrl          string `bson:"rpcUrl"`
	LastBlockNumber uint64 `bson:"lastBlockNumber"`
	Type            string `bson:"type"`
	UdunId          uint64 `bson:"udunId"`
}

func (s *ScanConfig) GetScanConfig(UdunId uint) error {
	client := global.DBEngine.Database(global.DBName).Collection("scan_config")
	filter := bson.M{"udunId": UdunId}
	err := client.FindOne(context.TODO(), filter).Decode(&s)
	return err
}
